/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package players;

import java.util.ArrayList;
import java.util.Iterator;
import main.Card;

/**
 *
 * @author theworldiwant
 */
public class IntPlayer extends Player {

    private int p; // ung input p

    public IntPlayer(int p) {
        cards = new ArrayList<Integer>();
        this.p = p;
    }

    /**
     * @return the p
     */
    public int getP() {
        return p;
    }

    /**
     * @param p the p to set
     */
    public void setP(int p) {
        this.p = p;
    }

    public boolean isAskForThird(Card c) {
        askForThird = executeStrategy(c);
        return askForThird;
    }

    public boolean executeStrategy(Card c) {
        int noOfCards = 4; //represents # of cards per symbol e.g. 1Spade = 4 in deck
        float probability = 0;

        int deckSize = c.getDeckSize();
        ArrayList distCard = c.getDistributedCard();
        int distribCard = distCard.size();
        int currentScore = getScore();
        System.out.print("Distributed Card: ");
        for (int ji = 0; ji < distribCard; ji++) {
            System.out.print(distCard.get(ji) + " ");
        }

        for (int i = 0; i < 10; i++) {
            if ((currentScore + i + 1) % 10 > currentScore) {
                for (int j = 0; j < distribCard; j++) {
                    if (i == distCard.get(j)) {
                        noOfCards--;
                    }
                }

                probability = (float) ((1.0 * noOfCards / deckSize) * 100.0);
                System.out.println("deck size:" + deckSize + "no of cards:" + noOfCards + " PROBABILITY:" + probability);
                if (probability >= p) {
                    return true;
                } else {
                    noOfCards = 4;
                }
            }
        }

        return false;
    }
}
